package com.example.demo.Test;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;

@RestController
public class Test1 {
    @Value("${demo.key2}")   //配置属性
    public String key1;

    @Value("${demo1.ken1}")
    public String ken1;

    @Value("${demo1.ken2}")
    public String ken2;

    @Value("${demo1.ken3}")
    public Boolean ken3;//String修饰就不可以用~然后代表空了

    @Value("${string.str1}")
    public String str1;
    @Value("${string.str2}")  //
    public String str2;
    @Value("${string.str3}")
    public String str3;


    @RequestMapping("test01")
    public String post(){
        return key1;
    }
    @Autowired   //配置对象
    public Student student;
    @Autowired
    public DBType dbType;        //配置集合以及map

    @PostConstruct    //对于一个函数，使用这个注解后就不可以再用映射的那个注解了
    public void init(){
        System.out.println("ken1="+ken1);
        System.out.println("ken2="+ken2);
        System.out.println("ken3="+ken3);  //
        System.out.println(ken3);

    }

    @PostConstruct
    public void init1(){
        System.out.println("str1="+str1);
        System.out.println("str2="+str2);
        System.out.println("str3="+str3);

    }
@PostConstruct
    public void init2(){
        System.out.println(student);
     System.out.println(dbType);
    }
}
